package vip.liux.backend.adapter.web;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import vip.liux.application.dots.ListResultDto;
import vip.liux.backend.application.service.point.PointsRuleDto;
import vip.liux.backend.application.service.point.PointsRuleService;
import vip.liux.contracts.shared.value.Select;

@RestController
@RequestMapping("/api/points-rule")
public class PointsRuleController {


    private final PointsRuleService pointsRuleService;

    public PointsRuleController(PointsRuleService pointsRuleService) {
        this.pointsRuleService = pointsRuleService;
    }

    /**
     * 获取积分规则列表
     *
     * @return 积分规则列表
     */
    @GetMapping("/select")
    public ListResultDto<Select> select() {
        return new ListResultDto<>(
                Select.fromList(pointsRuleService.list().getItems(), PointsRuleDto::getRuleName, PointsRuleDto::getRuleCode)
        );
    }
}
